From 1085ebc8ae84807ca1ed310e68af938c821af473 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Tue, 4 Nov 2003 15:01:40 +0000 Subject: [PATCH] bitkeeper revision 1.557 (3fa7bf54uSRjwiFPziJvGyBirhU24A) network.c, dom0_ops.h, processor.h, domain.c, dom0_ops.c, xi_build.c: More fixes and tweaks. --- tools/internal/xi_build.c | 16 +++++++--- xen/common/dom0_ops.c | 2 ++ xen/common/domain.c | 31 ++++++++----------- xen/include/asm-i386/processor.h | 3 +- xen/include/hypervisor-ifs/dom0_ops.h | 2 +- .../arch/xeno/drivers/network/network.c | 2 +- 6 files changed, 30 insertions(+), 26 deletions(-) diff --git a/tools/internal/xi_build.c b/tools/internal/xi_build.c index a08b6f8245..953a8205eb 100644 --- a/tools/internal/xi_build.c +++ b/tools/internal/xi_build.c @@ -9,6 +9,9 @@ #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED) #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) +static unsigned long virt_startinfo_addr; +static unsigned long startinfo_frame; + static char *argv0 = "internal_domain_build"; static long get_tot_pages(int domain_id) @@ -313,10 +316,11 @@ static int setup_guestos( num_pgt_updates++; } - builddomain->virt_startinfo_addr = + virt_startinfo_addr = virt_load_addr + ((alloc_index-1) << PAGE_SHIFT); + startinfo_frame = page_array[alloc_index-1]; - start_info = map_pfn(page_array[alloc_index-1]); + start_info = map_pfn(startinfo_frame); memset(start_info, 0, sizeof(*start_info)); start_info->pt_base = virt_load_addr + ((tot_pages-1) << PAGE_SHIFT); start_info->mod_start = initrd_addr; @@ -473,8 +477,8 @@ int main(int argc, char **argv) ctxt->i386_ctxt.ss = FLAT_RING1_DS; ctxt->i386_ctxt.cs = FLAT_RING1_CS; ctxt->i386_ctxt.eip = load_addr; - ctxt->i386_ctxt.esp = launch_op.u.builddomain.virt_startinfo_addr; - ctxt->i386_ctxt.esi = launch_op.u.builddomain.virt_startinfo_addr; + ctxt->i386_ctxt.esp = virt_startinfo_addr; + ctxt->i386_ctxt.esi = virt_startinfo_addr; ctxt->i386_ctxt.eflags = (1<<9) | (1<<2); /* FPU is set up to default initial state. */ @@ -496,7 +500,7 @@ int main(int argc, char **argv) /* Ring 1 stack is the initial stack. */ ctxt->ring1_ss = FLAT_RING1_DS; - ctxt->ring1_esp = launch_op.u.builddomain.virt_startinfo_addr; + ctxt->ring1_esp = virt_startinfo_addr; /* No debugging. */ memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg)); @@ -507,6 +511,8 @@ int main(int argc, char **argv) ctxt->failsafe_callback_cs = FLAT_RING1_CS; ctxt->failsafe_callback_eip = 0; + ctxt->start_info_frame = startinfo_frame; + launch_op.u.builddomain.domain = domain_id; launch_op.u.builddomain.num_vifs = atoi(argv[3]); diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index aad13c5626..9d820126e3 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -321,6 +321,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op) p->failsafe_selector; op.u.getdomaininfo.ctxt.failsafe_callback_eip = p->failsafe_address; + op.u.getdomaininfo.ctxt.start_info_frame = + p->thread.start_info_frame; } } read_unlock_irqrestore(&tasklist_lock, flags); diff --git a/xen/common/domain.c b/xen/common/domain.c index e5c590a061..b8b015f8c4 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -325,7 +325,7 @@ void release_task(struct task_struct *p) */ int final_setup_guestos(struct task_struct *p, dom0_builddomain_t *builddomain) { - start_info_t *virt_startinfo_addr; + start_info_t *startinfo; unsigned long phys_l2tab; net_ring_t *shared_rings; net_vif_t *net_vif; @@ -365,6 +365,7 @@ int final_setup_guestos(struct task_struct *p, dom0_builddomain_t *builddomain) p->event_address = builddomain->ctxt.event_callback_eip; p->failsafe_selector = builddomain->ctxt.failsafe_callback_cs; p->failsafe_address = builddomain->ctxt.failsafe_callback_eip; + p->thread.start_info_frame = builddomain->ctxt.start_info_frame; /* NB. Page base must already be pinned! */ phys_l2tab = builddomain->ctxt.pt_base; @@ -375,18 +376,12 @@ int final_setup_guestos(struct task_struct *p, dom0_builddomain_t *builddomain) /* Set up the shared info structure. */ update_dom_time(p->shared_info); - virt_startinfo_addr = (start_info_t *)builddomain->virt_startinfo_addr; - - /* - * We need to populate start_info struct within the context of the new - * domain. Thus temporarely install its pagetables. - */ - __cli(); - __asm__ __volatile__ ( - "mov %%eax,%%cr3" : : "a" (pagetable_val(p->mm.pagetable))); + startinfo = (start_info_t *) + map_domain_mem(p->thread.start_info_frame << PAGE_SHIFT); /* Add virtual network interfaces and point to them in startinfo. */ - while (builddomain->num_vifs-- > 0) { + while ( builddomain->num_vifs-- > 0 ) + { net_vif = create_net_vif(p->domain); shared_rings = net_vif->shared_rings; if (!shared_rings) panic("no network ring!\n"); @@ -395,19 +390,16 @@ int final_setup_guestos(struct task_struct *p, dom0_builddomain_t *builddomain) for ( i = 0; i < MAX_DOMAIN_VIFS; i++ ) { if ( p->net_vif_list[i] == NULL ) continue; - virt_startinfo_addr->net_rings[i] = + startinfo->net_rings[i] = virt_to_phys(p->net_vif_list[i]->shared_rings); - memcpy(virt_startinfo_addr->net_vmac[i], + memcpy(startinfo->net_vmac[i], p->net_vif_list[i]->vmac, ETH_ALEN); } /* Add block io interface */ - virt_startinfo_addr->blk_ring = virt_to_phys(p->blk_ring_base); + startinfo->blk_ring = virt_to_phys(p->blk_ring_base); - /* Reinstate the caller's page tables. */ - __asm__ __volatile__ ( - "mov %%eax,%%cr3" : : "a" (pagetable_val(current->mm.pagetable))); - __sti(); + unmap_domain_mem(startinfo); p->flags |= PF_CONSTRUCTED; @@ -589,6 +581,9 @@ int setup_guestos(struct task_struct *p, dom0_createdomain_t *params, update_dom_time(p->shared_info); p->shared_info->domain_time = 0; + /* DOM0 can't be stopped/started, so no need for an ongoing s.i. frame. */ + p->thread.start_info_frame = 0; + virt_startinfo_address = (start_info_t *) (virt_load_address + ((alloc_index - 1) << PAGE_SHIFT)); virt_stack_address = (unsigned long)virt_startinfo_address; diff --git a/xen/include/asm-i386/processor.h b/xen/include/asm-i386/processor.h index 4ba8010338..6d05a61c75 100644 --- a/xen/include/asm-i386/processor.h +++ b/xen/include/asm-i386/processor.h @@ -354,6 +354,7 @@ struct tss_struct { }; struct thread_struct { + unsigned long start_info_frame; /* Filled in on DOM0_START */ unsigned long esp1, ss1; /* Hardware debugging registers */ unsigned long debugreg[8]; /* %%db0-7 debug registers */ @@ -385,7 +386,7 @@ extern struct desc_struct *idt_tables[]; long set_fast_trap(struct task_struct *p, int idx); #define INIT_THREAD { \ - 0, 0, \ + 0, 0, 0, \ { [0 ... 7] = 0 }, /* debugging registers */ \ { { 0, }, }, /* 387 state */ \ 0x20, { 0, 0 }, /* DEFAULT_FAST_TRAP */ \ diff --git a/xen/include/hypervisor-ifs/dom0_ops.h b/xen/include/hypervisor-ifs/dom0_ops.h index 25708736c6..cff8bca48c 100644 --- a/xen/include/hypervisor-ifs/dom0_ops.h +++ b/xen/include/hypervisor-ifs/dom0_ops.h @@ -41,6 +41,7 @@ typedef struct full_execution_context_st unsigned long event_callback_eip; unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */ unsigned long failsafe_callback_eip; + unsigned long start_info_frame; /* Page frame containing s.i. */ } full_execution_context_t; #define MAX_CMD_LEN 256 @@ -94,7 +95,6 @@ typedef struct dom0_builddomain_st { /* IN variables. */ unsigned int domain; - unsigned long virt_startinfo_addr; unsigned int num_vifs; full_execution_context_t ctxt; } dom0_builddomain_t; diff --git a/xenolinux-2.4.22-sparse/arch/xeno/drivers/network/network.c b/xenolinux-2.4.22-sparse/arch/xeno/drivers/network/network.c index 31611b433e..913acc7ab6 100644 --- a/xenolinux-2.4.22-sparse/arch/xeno/drivers/network/network.c +++ b/xenolinux-2.4.22-sparse/arch/xeno/drivers/network/network.c @@ -517,7 +517,7 @@ int __init init_module(void) goto fail; } - err = request_irq(_EVENT_DEBUG, dbg_network_int, SA_SHIRQ, "debug", NULL); + err = request_irq(_EVENT_DEBUG, dbg_network_int, 0, "debug", NULL); if ( err ) printk(KERN_WARNING "Non-fatal error -- no debug interrupt\n"); -- 2.30.2